home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Wipes ƒ / Split scroll U-D.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-09  |  3.5 KB  |  108 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Split scroll U-D.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define CorrectTime 4
  32. #define theWindowWidth (boundsRect.right-boundsRect.left)
  33. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  34.  
  35. pascal short SplitScrollUD(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  36.  
  37. /* Draw a line from the topleft to the bottomright of the screen and split the
  38.    screen into two regions.  The top region scrolls down and the bottom region
  39.    scrolls up. */
  40.    
  41. pascal short SplitScrollUD(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  42. {
  43.     int            x;
  44.     Rect        theTopRect, topdest, theBottomRect, bottomdest;
  45.     Rect        topscrollsource, topscrolldest, bottomscrollsource, bottomscrolldest;
  46.     RgnHandle    toprgn,bottomrgn;
  47.     int            BoxSize;
  48.     
  49.     BoxSize=theWindowHeight/25;
  50.     toprgn=NewRgn();
  51.     SetEmptyRgn(toprgn);
  52.     MoveTo(0,0);
  53.     OpenRgn();
  54.         Line(theWindowWidth,0);
  55.         Line(0,theWindowHeight);
  56.         LineTo(0,0);
  57.     CloseRgn(toprgn);
  58.     OffsetRgn(toprgn, boundsRect.left, boundsRect.top);
  59.     
  60.     bottomrgn=NewRgn();
  61.     SetEmptyRgn(bottomrgn);
  62.     MoveTo(0,0);
  63.     OpenRgn();
  64.         Line(0,theWindowHeight);
  65.         Line(theWindowWidth,0);
  66.         LineTo(0,0);
  67.     CloseRgn(bottomrgn);
  68.     OffsetRgn(bottomrgn, boundsRect.left, boundsRect.top);
  69.     
  70.     topscrollsource=boundsRect;
  71.     topscrollsource.bottom-=BoxSize;
  72.     topscrolldest = topscrollsource;
  73.     OffsetRect(&topscrolldest, 0, BoxSize);
  74.     topdest = boundsRect;
  75.     topdest.bottom=topdest.top+BoxSize;
  76.     SetRect(&theTopRect, boundsRect.left, boundsRect.bottom-BoxSize, boundsRect.right, boundsRect.bottom);
  77.     
  78.     bottomscrollsource=boundsRect;
  79.     bottomscrollsource.top+=BoxSize;
  80.     bottomscrolldest=bottomscrollsource;
  81.     OffsetRect(&bottomscrolldest, 0, -BoxSize);
  82.     bottomdest=boundsRect;
  83.     bottomdest.top=bottomdest.bottom-BoxSize;
  84.     SetRect(&theBottomRect, boundsRect.left, boundsRect.top, boundsRect.right, boundsRect.top+BoxSize);
  85.     
  86.     for(x = theWindowHeight - BoxSize; x >= 0; x -= BoxSize)
  87.     {
  88.         StartTiming();
  89.         CopyBits(&(destGrafPtr->portBits), &(destGrafPtr->portBits),
  90.                 &topscrollsource, &topscrolldest, 0, toprgn);
  91.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  92.                 &theTopRect, &topdest, 0, toprgn);
  93.         theTopRect.bottom-=BoxSize;
  94.         theTopRect.top-=BoxSize;
  95.         
  96.         CopyBits(&(destGrafPtr->portBits), &(destGrafPtr->portBits),
  97.                 &bottomscrollsource, &bottomscrolldest, 0, bottomrgn);
  98.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  99.                 &theBottomRect, &bottomdest, 0, bottomrgn);
  100.         theBottomRect.top+=BoxSize;
  101.         theBottomRect.bottom+=BoxSize;
  102.         
  103.         TimeCorrection(CorrectTime);
  104.     }
  105.     
  106.     return 0;
  107. }
  108.